package cn.zs.supply.web.interceptor;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.ArrayList;
import java.util.List;

//@Configuration
//@ConfigurationProperties(prefix = "config.path")  //读取配置文件
//@Data
public class InterceptorConfig implements WebMvcConfigurer {

    private List<String> special = new ArrayList<>();

    private List<String> exclude = new ArrayList<>();
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

    registry.addInterceptor(configPathInterceptor())
                .excludePathPatterns(exclude)   //  不拦截
                .addPathPatterns(special); //  拦截
    }


    @Bean
    public ConfigPathInterceptor configPathInterceptor() {
        return new ConfigPathInterceptor();
    }



}
